
<template>
  <div class="editForm-wrapper">
    <!-- 客户编辑dialog-->
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      v-dialogDrag
      :visible.sync="editVisible"
    >
      <el-form
        label-width="125px"
        ref="editForm"
        :model="editForm"
      >
        <el-form-item label="业务编号:" prop="codes">
          <el-input v-model="editForm.codes" :disabled="true"></el-input>
        </el-form-item>
        <el-form-item label="客户名称:" prop="companyName" >
          <el-input v-model="editForm.companyName" :disabled="true"></el-input>
        </el-form-item>
        <el-form-item label="产品名称:" prop="productId" :rules="[
                  {required: true, message:'请选择产品', trigger:'blur'}
                 ]">
<!--          <el-input v-model="editForm.productName" :disabled="true"></el-input>-->
          <el-select clearable v-model="editForm.productId" placeholder="请选择产品" >
            <el-option
              v-for="item in editForm.selectVos"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="调整价格:" prop="newPrice" :rules="[
                  {required: true, message:'请输入调整价格', trigger:'blur'},
                  {validator:onlyNumber, trigger:'blur'}
                 ]">
          <el-input v-model="editForm.newPrice" v-thousands.newPrice="editForm" @input="ss1"></el-input>
        </el-form-item>
        <el-form-item label="支付方式:" prop="payMode" :rules="[
                  {required: true, message:'请选择支付方式', trigger:'blur'}
                 ]">
          <el-select clearable v-model="editForm.payMode" placeholder="请选择支付方式">
            <el-option
              v-for="item in  $dictUtils.getDictList('payMode')"
              :key="item.value"
              :label="item.label"
              :value="Number(item.value)">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="开始执行时间:" prop="effectTime"
                      :rules="[
                  {required: true, message:'请输入执行时间', trigger:'blur'}
                 ]">
          <el-date-picker
            v-model="editForm.effectTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="选择日期时间"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
          <el-button size="small"  type="primary" @click="doSubmit(false)" v-noMoreClick>确定</el-button>
          <el-button size="small"  type="warning" @click="doSubmit(true)" v-noMoreClick>提交</el-button>
          <el-button size="small" @click="close()">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { saveAdjust } from '@/api/business/business.js'
export default {
  components: {
  },
  data () {
    return {
      areaLabel: {},
      method: '',
      title: '',
      editForm: {
        businessProductId: '',
        procInsId: '',
        businessId: '',
        productId: '',
        payMode: 0,
        selectVos: [],
        companyName: '',
        price: '',
        productName: '',
          codes: '',
        effectTime: '',
        newPrice: ''
      },
      editVisible: false,
      detailsVisible: false,
      dataRule: {
        contactName: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
        // productName: [
        //   { required: true, message: '请选择产品类型', trigger: 'change' }
        // ],
        creditQuatity: [
          { required: false, message: '请输入信用量', trigger: 'blur' }
        ]
      },
      tableData1: [],
      page: {
        pageSize: 10,
        pageNo: 1,
        total: 0
      },
      props: 1,
      dialogVisible: false,
      query: ''
    }
  },
  methods: {
    ss1(e){
      console.log(e)
    },
  	handleClose(done) {
				this.$Msg.confirm({
					title:'您确定要关闭吗？',
					content:this.GLOBAL.FORM_CLOSE_TIPS,
					confirmCall:()=>{
						done();
					}
				})
			},
    select (e) {
      this.editForm.companyName = e.names
      this.editForm.companyId = e.id
      this.dialogVisible = false
      console.log(e)
    },
    onlyNumber (rule, value, callback) {
      if (value && !(/^[1-9]\d*$/).test(value)) {
        callback(new Error('只能填写正整数'))
      } else {
        callback()
      }
    },
    init (editForm) {
      this.editVisible = true
      this.$nextTick(() => {
        this.$refs.editForm.resetFields()
        this.editForm = editForm
      })
      this.title = '销售调价'
    },
    getArea1 (e) {
      if (e.province !== '' && e.city !== '' && e.district !== '') {
        this.editForm.countyCode = JSON.stringify(e)
      } else {
        this.editForm.countyCode = ''
      }
    },
    close () {
      this.editVisible = false
    },
    doSubmit (isFlowable) {
      this.$refs['editForm'].validate((valid) => {
        if (valid) {
            this.$set(this.editForm, 'processType', 1)
            this.$set(this.editForm, 'isFlowable', isFlowable)
          saveAdjust(this.editForm).then((res) => {
            if (res.data.code === '200') {
              this.$message({
                message: '编辑成功',
                type: 'success'
              })
              this.editVisible = false
              this.$emit('refreshDataList')
            }
          })
        }
      })
    }
  },
  mounted () {
    // this.getList(this.page, 1)
  }
}
</script>
<style lang="scss" scoped>

</style>
